def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True


def closest_prime_number(s):
    words = s.split()
    num_dict = {
        'zero': 0, 'one': 1, 'two': 2, 'three': 3,
        'four': 4, 'five': 5, 'six': 6, 'seven': 7,
        'eight': 8, 'nine': 9
    }

    if len(words) != 3:
        print("wrong input")
        return

    num = int(''.join(str(num_dict[word]) for word in words))

    if num < 100 or num > 999:
        print("wrong input")
        return

    lower_prime = num
    upper_prime = num
    while True:
        if is_prime(lower_prime):
            print(lower_prime)
            return
        if is_prime(upper_prime):
            print(upper_prime)
            return
        lower_prime -= 1
        upper_prime += 1


input_text = input("Введите числа: ")
closest_prime_number(input_text)